var app = getApp()
var appData = app.globalData
Page({
   data: {
      isShowSubmenu: [false, false, false,false],
      userInfo: ''
   },

   showAndHideSubmenu: function (e) {
      var index = Number(e.currentTarget.id)
      var isShowArray = [];
      for (var i = 0; i < this.data.isShowSubmenu.length; i++) {
         isShowArray.push(index == i ? true : false);
      }
      this.setData({ isShowSubmenu: isShowArray })
   },

   onLoad: function (options) {
      console.log('appData.shopInfo===', appData.shopInfo)
      this.setData({ userInfo: appData.shopInfo })
      wx.setNavigationBarTitle({
         title: this.data.userInfo.Biz_Name + '后台',
      })
   },

   onShow: function (opt) {
      console.log('生命周期函数--监听页面显示opt', opt)
      var appUser = appData.shopInfo
      console.log('this.data', this.data)
      if (appUser.Biz_ID != this.data.userInfo.Biz_ID) {
         console.log('开始重载')
         this.onLoad()
      }
   },

   myInfo: function () {
      this.goto('02admin/00shop/shopSet')
   },

   toWaiter: function () {
      this.goto('02admin/00waiter/waiter')
   },

   toTableClass: function () {
      this.goto('02admin/02tableClass/tableClass')
   },

   toTable: function () {
      this.goto('02admin/03table/table')
   },

   setGoodsClass: function () {
      this.goto('02admin/10goodsCate/goodsCate')
   },

   shelvesGoods: function () {
      if (appData.loginMode == 'boss') {
         this.goto('02admin/12goodsShelves/goodsShelves')
      } else {
         app.toast('需要掌柜登录才能操作')
      }
   },

   sellingGoods: function () {
      this.goto('02admin/13sellingGoods/sellingGoods')
   },

   warehouseGoods: function () {
      this.goto('02admin/14warehouseGoods/warehouseGoods')
   },

   goodsList: function () {
      this.goto('02admin/15goodsList/goodsList')
   },
   
   report: function () {
      this.goto('02admin/16report/report')
   },

   toManageStatement:function(){
      this.goto('02admin/04manageStatement/manageStatement')
   },
   
   toIndustryData:function(){
      this.goto('02admin/05industryData/industryData')
   },

   toWechatClass: function () {
      this.goto('03setup/00aboutQzg/aboutQzg')
   },
   //测试
   // ces: function () {
   //    this.goto('03setup/03ces/ces')
   // },

   toHelp: function () {
      this.goto('03setup/01help/helpCenter')
   },

   setWifiPrinter: function () {
      if (appData.loginMode == 'boss') {
         this.goto('03setup/02printer/printerSet')
      } else {
         app.toast('需要掌柜登录才能操作')
      }
   },

   toSetPrinter: function () {
      if (appData.loginMode == 'boss') {
         this.goto('03setup/02setPrinter/setPrinter')
      } else {
         app.toast('需要掌柜登录才能操作')
      }
   },

   setOut: function () {
      if (appData.client_id.length == 20) {//如果登录着，先退出
         app.readyWebsocket()
      }
      appData.shopInfo = ''
      this.goto('00login/login')
   },

   goto: function (path) {
      wx.navigateTo({
         url: '/pages/' + path
      })
   },
   //用户点击右上角分享
   onShareAppMessage: function () {
      var userInfoStr = JSON.stringify(this.data.loginGuestInfo)
      return {
         title: appData.guestInfo.name + '邀请您来【桥掌柜】当掌柜',
         path: '/pages/00login/login?str=' + userInfoStr
      }
   }
})
